//
//  AES128.m
//  WBUQ
//
//  Created by yangaichun on 15/11/19.
//  Copyright © 2015年 com.weiba66. All rights reserved.
//

#import "AES128.h"
#import "NSData+AES.h"

//密钥
#define AES_KEY  @"U1MjU1M0FDOUZ.Qz"

@implementation AES128

+ (NSString *)AES128Encrypt:(NSString *)surString;{
    
    return [self AES128Encrypt:surString Key:AES_KEY];
}

+ (NSString *)AES128Encrypt:(NSString *)surString Key:(NSString *)key;{

    NSData *data = [surString dataUsingEncoding:NSUTF8StringEncoding];
    NSData *encryptData =[data AES128EncryptWithKey:key];
    NSString *base64String = [encryptData base64EncodedStringWithOptions:0];
    return base64String;
}


+ (NSString *)AES128Decrypt:(NSString *)base64String;{
    return [self AES128Decrypt:base64String Key:AES_KEY];
}


+ (NSString *)AES128Decrypt:(NSString *)base64String Key:(NSString *)key;{
   
    if (!base64String) {
        return nil;
    }
    NSData *data = [[NSData alloc]initWithBase64EncodedString:base64String options:0];
    NSData *decryptData =[data AES128DecryptWithKey:key];
    NSString *surString = [[NSString alloc]initWithData:decryptData encoding:NSUTF8StringEncoding];
    return surString;
}

@end
